var User={
	// 插询用户和手机号
	queryUserName(param){
		if(param.userName){
			return "select * from user where userName ='"+param.userName+"' or phone ='"+param.userName+"'";
		}else{
			return "select * from user where provider ='"+param.provider+"' or openId ='"+param.openId+"'";
		}
		
	},
	// 验证用户名和密码
	queryUserPwd(param){
		return "select * from user where userName ='"+param.userName+"' and userPwd ='"+param.userPwd+"' or phone ='"+param.userName+"' and userPwd ='"+param.userPwd+"'";
	},
	// 增加一条用户数据
	addUser(param){
		let userName=param.userName || param.openId
		
		const jwt=require('jsonwebtoken');
		
		let payload={name:userName};
		
		let secret ='tatakai';
		
		let token =jwt.sign(payload,secret);
		
		let nickName =param.nickName || '默认昵称';
		
		let img =param.avatarUrl || '../../static/img/background_3修.jpg';
		
		
		return "insert into user (userName,userPwd,phone,imgUrl,nickName,token,provider,openId) values('','','"+userName+"','"+img+"','"+nickName+"','"+token+"','"+param.provider+"','"+param.openId+"')";
	}
}
exports =module.exports=User;